package com.my.study.consumer;

import com.my.study.bean.PrintBean;
import com.my.study.common.constant.TopicConstants;
import com.my.study.utils.JSONUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 消息消费者
 *
 * @author: yidujun
 * @create: 2021/07/23 10:09
 */
@Component("msgConsumer")
public class MsgConsumer {

    @KafkaListener(topics = TopicConstants.TOPIC12, properties = "max.poll.records=2")
    public void consumerMsg(List<ConsumerRecord<String, String>> records) {

        System.out.println(records.size());
//        String key = record.key();
//        String value = record.value();
//
//        PrintBean printBean = JSONUtils.parseObject(value, PrintBean.class);
//        System.out.println(printBean.getMsg());
//        System.out.println(record.toString());
    }

}
